﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Lilium.Control.Reactive;
using Lilium.UI.Controls;
using Lilium.UI.Layout;

namespace Lilium.UI
{
    public sealed class UIState<TControlFamily> : IUIState
    {
        public UIState(IControlFactory<TControlFamily> controlFactory, ILayout<TControlFamily> layout)
        {
            if (controlFactory == null) throw new ArgumentNullException("controlFactory");
            if (layout == null) throw new ArgumentNullException("layout");


            m_ControlFactory = controlFactory;
            m_Layout = layout;
        }

        public ILabel CreateLabel()
        {
            var label = ControlFactory.CreateLabel();
            Layout.Add(label.Control);
            return label.Adapter;
        }

        #region private IControlFactory ControlFactory

        private readonly IControlFactory<TControlFamily> m_ControlFactory;

        private IControlFactory<TControlFamily> ControlFactory { get { return m_ControlFactory; } }

        #endregion

        #region private ILayout<TControlFamily> Layout

        private ILayout<TControlFamily> m_Layout;

        private ILayout<TControlFamily> Layout { get { return m_Layout; } set { m_Layout = value; } }

        #endregion
    }
}